import java.io.File;

public class FileMain {

    public static void main(String[] args) {

        String path = "D:\\";
        File file = new File(path);
        File[] files = file.listFiles();//遍历path路径下的文件和目录
        for (File f : files){ //遍历File[]数组
            if (!f.isDirectory()){//若非目录(即文件)，则打印
                System.out.println(f);
            }
        }
    }
}
